package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.business.domain.NursingRecordsDTO;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.NursingRecords;
import com.elder.business.service.INursingRecordsService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 护理记录Controller
 * 
 * @author zyk
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/nurseRecords")
public class NursingRecordsController extends BaseController
{
    @Autowired
    private INursingRecordsService nursingRecordsService;

    /**
     * 查询护理记录列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String elderName,Integer pageNum,Integer pageSize)
    {
        return nursingRecordsService.selectNursingRecordsList(elderName,pageNum,pageSize);
    }

    /**
     * 导出护理记录列表
     */
//    @Anonymous
//    @Log(title = "护理记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, NursingRecords nursingRecords)
//    {
//        List<NursingRecords> list = nursingRecordsService.selectNursingRecordsList(nursingRecords);
//        ExcelUtil<NursingRecords> util = new ExcelUtil<NursingRecords>(NursingRecords.class);
//        util.exportExcel(response, list, "护理记录数据");
//    }

    /**
     * 获取护理记录详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(nursingRecordsService.selectNursingRecordsById(id));
    }

    /**
     * 新增护理记录
     */
    @Anonymous
    @Log(title = "护理记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NursingRecordsDTO nursingRecords)
    {
        return toAjax(nursingRecordsService.insertNursingRecords(nursingRecords));
    }

    /**
     * 修改护理记录
     */
    @Anonymous
    @Log(title = "护理记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NursingRecordsDTO nursingRecords)
    {
        return toAjax(nursingRecordsService.updateNursingRecords(nursingRecords));
    }

    /**
     * 删除护理记录
     */
    @Anonymous
    @Log(title = "护理记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nursingRecordsService.deleteNursingRecordsByIds(ids));
    }
}
